package wildlife;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

public class forum {
String post;
int flag; //0 for myposts 1 for all posts
String date;

public String getDate() {
	return date;
}
public void setDate(String date) {
	this.date = date;
}
public int getFlag() {
	return flag;
}
public void setFlag(int flag) {
	this.flag = flag;
}
public String getPost() {
	return post;
}
public void setPost(String post) {
	this.post = post;
}
public String getUsername() {
	return username;
}
public void setUsername(String username) {
	this.username = username;
}
String username;
private ArrayList<forum> posts = new ArrayList<forum>();
public String execute() throws SQLException
{
	Connect c=new Connect();
	HttpServletRequest request=ServletActionContext.getRequest();
	HttpSession session=request.getSession();
	String username=session.getAttribute("username")+"";
	String query="select * from notifications where username='"+username+"' and approved=1";
	ResultSet rs=c.getResult(query);
	while(rs.next())
	{
		forum f=new forum();
		f.setPost(rs.getString("notification"));
		f.setDate(rs.getTimestamp("date")+"");
		posts.add(f);
	}
	return "success";
}
public void setPosts(ArrayList<forum> posts) {
	this.posts = posts;
}
public ArrayList<forum> getPosts() {
	return posts;
}

}
